package com.heyun.service.impl;


import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;










import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.heyun.bean.HeyunDept;
import com.heyun.bean.HeyunSalesPlan;
import com.heyun.bean.HeyunSalesPre;
import com.heyun.dao.SalesPreDao;
import com.heyun.service.SalesPreService;
@Service
public class SalesPreServiceImpl implements SalesPreService {
	@Autowired
	private SalesPreDao  salespredao;
    
	@Override
	public List<HeyunDept> getDeptName() {
		System.out.println("......>>>>>>>>>>>>");
		List<HeyunDept> deptlist=salespredao.getDeptName();
		return deptlist;
	}

	@Override
	public HeyunDept getCustomsAndPersons(int deptId) {
		HeyunDept hyd=salespredao.getCustomsAndPersons(deptId);
		return hyd;
	}
    //保存销售预测数据
	@Override
	public void saveSalesPre(HeyunSalesPre hsp) {
		// TODO Auto-generated method stub
		salespredao.saveSalesPre(hsp);
	}
   //获取销售预测数据,用于页面table展示
	@Override
	public Map<String,Object> getSalesPre(int currentPage) {
		PageHelper.startPage(currentPage,3);//每一页显示三条数据
		List<HeyunSalesPre> hsplist=salespredao.getSalesPre();
		PageInfo<HeyunSalesPre> p=new PageInfo<HeyunSalesPre>(hsplist);
		Map<String,Object> map=new HashMap<String,Object>();
		map.put("hsplist", hsplist);
		map.put("totalPage", p.getPages());
		return map;
	}

	@Override
	public Map<String, Object> findSalesPreByMonth(int currentPage,String preMonth) {
		PageHelper.startPage(currentPage,3);//每一页显示三条数据
		List<HeyunSalesPre> hsplist=salespredao.findSalesPreByMonth(preMonth);
		PageInfo<HeyunSalesPre> p=new PageInfo<HeyunSalesPre>(hsplist);
	
		Map<String,Object> map=new HashMap<String,Object>();
		map.put("hsplist", hsplist);
		for(HeyunSalesPre hsp:hsplist){
			System.out.println(""+hsp.getPreResultTitle());
		}
		map.put("totalPage", p.getPages());
		return map;
		
	}

	@Override
	public HeyunSalesPre findSalesPreById(int salesPreId) {
		// TODO Auto-generated method stub
		HeyunSalesPre hsp=salespredao.findSalesPreById(salesPreId);
		
		return hsp;
	}

	
}
